// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   register_ok.java

package hr.training;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			PrintWriter out = response.getWriter();
			nseer_db_backup1 hr_db = new nseer_db_backup1(dbApplication);
			if (hr_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String major_first_kind_ID = "";
				String major_first_kind_name = "";
				String major_second_kind_ID = "";
				String major_second_kind_name = "";
				String major_first_kind = request.getParameter("human_major_first_kind");
				for (StringTokenizer tokenTO4 = new StringTokenizer(major_first_kind, "/"); tokenTO4.hasMoreTokens();)
				{
					major_first_kind_ID = tokenTO4.nextToken();
					major_first_kind_name = tokenTO4.nextToken();
				}

				String major_second_kind = request.getParameter("human_major_second_kind");
				for (StringTokenizer tokenTO5 = new StringTokenizer(major_second_kind, "/"); tokenTO5.hasMoreTokens();)
				{
					major_second_kind_ID = tokenTO5.nextToken();
					major_second_kind_name = tokenTO5.nextToken();
				}

				String human_ID = request.getParameter("human_ID");
				String human_name = request.getParameter("human_name");
				String training_item = request.getParameter("training_item");
				String training_hour = request.getParameter("training_hour");
				String training_result_degree = request.getParameter("training_result_degree");
				String register = request.getParameter("register");
				String register_time = request.getParameter("register_time");
				String chain_name = request.getParameter("chain_name");
				String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
				String remark = exchange.toHtml(bodyc);
				int training_time = 1;
				try
				{
					String sql = (new StringBuilder("select training_time from hr_training where human_ID='")).append(human_ID).append("' order by training_time desc").toString();
					ResultSet m_rs = hr_db.executeQuery(sql);
					if (m_rs.next())
						training_time = m_rs.getInt("training_time") + 1;
					sql = (new StringBuilder("insert into hr_training(chain_name,human_major_first_kind_ID,human_major_first_kind_name,human_major_second_kind_ID,human_major_second_kind_name,human_ID,human_name,training_item,training_hour,training_result_degree,register,register_time,remark,training_time) values ('")).append(chain_name).append("','").append(major_first_kind_ID).append("','").append(major_first_kind_name).append("','").append(major_second_kind_ID).append("','").append(major_second_kind_name).append("','").append(human_ID).append("','").append(human_name).append("','").append(training_item).append("','").append(training_hour).append("','").append(training_result_degree).append("','").append(register).append("','").append(register_time).append("','").append(remark).append("','").append(training_time).append("')").toString();
					hr_db.executeUpdate(sql);
					String sql1 = (new StringBuilder("update hr_file set training_check_tag='1' where human_ID='")).append(human_ID).append("'").toString();
					hr_db.executeUpdate(sql1);
					List rsList = new ArrayList();
					String elem[] = new String[3];
					sql = "select id,describe1,describe2 from hr_config_workflow where type_id='05'";
					for (ResultSet rset = hr_db.executeQuery(sql); rset.next(); rsList.add(elem))
					{
						elem = new String[3];
						elem[0] = rset.getString("id");
						elem[1] = rset.getString("describe1");
						elem[2] = rset.getString("describe2");
					}

					if (rsList.size() == 0)
					{
						sql = (new StringBuilder("update hr_training set check_tag='1' where human_ID='")).append(human_ID).append("' and training_time='").append(training_time).append("'").toString();
						hr_db.executeUpdate(sql);
						sql = (new StringBuilder("select * from hr_file where human_ID='")).append(human_ID).append("'").toString();
						ResultSet rs = hr_db.executeQuery(sql);
						if (rs.next())
						{
							String sqll = (new StringBuilder("insert into hr_file_dig(chain_id,chain_name,HUMAN_ID,HUMAN_NAME,HUMAN_ADDRESS,HUMAN_POSTCODE,HUMAN_TITLE_CLASS,HUMAN_MAJOR_FIRST_KIND_ID,HUMAN_MAJOR_FIRST_KIND_NAME,HUMAN_MAJOR_SECOND_KIND_ID,HUMAN_MAJOR_SECOND_KIND_NAME,HUMAN_BANK,HUMAN_ACCOUNT,HUMAN_TEL,HUMAN_HOME_TEL,HUMAN_CELLPHONE,HUMAN_EMAIL,HOBBY,SPECIALITY,SEX,RELIGION,PARTY,NATIONALITY,RACE,BIRTHDAY,BIRTHPLACE,AGE,EDUCATED_DEGREE,EDUCATED_YEARS,EDUCATED_MAJOR,SIN,IDCARD,MAJOR_TYPE,SALARY_STANDARD_ID,SALARY_STANDARD_NAME,SALARY_SUM,DEMAND_SALARY_SUM,PAID_SALARY_SUM,MAJOR_CHANGE_AMOUNT,BONUS_AMOUNT,TRAINING_AMOUNT,HISTORY_RECORDS,FAMILY_MEMBERSHIP,REMARK,PICTURE,ATTACHMENT_NAME,CHECK_TAG,FILE_CHANGE_AMOUNT,REGISTER,CHECKER,CHANGER,REGISTER_ID,CHECKER_ID,CHANGER_ID,REGISTER_TIME,CHECK_TIME,CHANGE_TIME,LATELY_CHANGE_TIME,DELETE_TIME,RECOVERY_TIME,EXCEL_TAG,CHANGE_TAG,MAJOR_CHANGE_TAG,TRAINING_CHECK_TAG,BONUS_CHECK_TAG,LICENSE_TAG) values('")).append(rs.getString("chain_id")).append("','").append(rs.getString("chain_name")).append("','").append(rs.getString("HUMAN_ID")).append("','").append(rs.getString("HUMAN_NAME")).append("','").append(rs.getString("HUMAN_ADDRESS")).append("','").append(rs.getString("HUMAN_POSTCODE")).append("','").append(rs.getString("HUMAN_TITLE_CLASS")).append("','").append(rs.getString("HUMAN_MAJOR_FIRST_KIND_ID")).append("','").append(rs.getString("HUMAN_MAJOR_FIRST_KIND_NAME")).append("','").append(rs.getString("HUMAN_MAJOR_SECOND_KIND_ID")).append("','").append(rs.getString("HUMAN_MAJOR_SECOND_KIND_NAME")).append("','").append(rs.getString("HUMAN_BANK")).append("','").append(rs.getString("HUMAN_ACCOUNT")).append("','").append(rs.getString("HUMAN_TEL")).append("','").append(rs.getString("HUMAN_HOME_TEL")).append("','").append(rs.getString("HUMAN_CELLPHONE")).append("','").append(rs.getString("HUMAN_EMAIL")).append("','").append(rs.getString("HOBBY")).append("','").append(rs.getString("SPECIALITY")).append("','").append(rs.getString("SEX")).append("','").append(rs.getString("RELIGION")).append("','").append(rs.getString("PARTY")).append("','").append(rs.getString("NATIONALITY")).append("','").append(rs.getString("RACE")).append("','").append(rs.getString("BIRTHDAY")).append("','").append(rs.getString("BIRTHPLACE")).append("','").append(rs.getString("AGE")).append("','").append(rs.getString("EDUCATED_DEGREE")).append("','").append(rs.getString("EDUCATED_YEARS")).append("','").append(rs.getString("EDUCATED_MAJOR")).append("','").append(rs.getString("SIN")).append("','").append(rs.getString("IDCARD")).append("','").append(rs.getString("MAJOR_TYPE")).append("','").append(rs.getString("SALARY_STANDARD_ID")).append("','").append(rs.getString("SALARY_STANDARD_NAME")).append("','").append(rs.getString("SALARY_SUM")).append("','").append(rs.getString("DEMAND_SALARY_SUM")).append("','").append(rs.getString("PAID_SALARY_SUM")).append("','").append(rs.getString("MAJOR_CHANGE_AMOUNT")).append("','").append(rs.getString("BONUS_AMOUNT")).append("','").append(rs.getString("TRAINING_AMOUNT")).append("','").append(rs.getString("HISTORY_RECORDS")).append("','").append(rs.getString("FAMILY_MEMBERSHIP")).append("','").append(rs.getString("REMARK")).append("','").append(rs.getString("PICTURE")).append("','").append(rs.getString("ATTACHMENT_NAME")).append("','").append(rs.getString("CHECK_TAG")).append("','").append(rs.getString("FILE_CHANGE_AMOUNT")).append("','").append(rs.getString("REGISTER")).append("','").append(rs.getString("CHECKER")).append("','").append(rs.getString("CHANGER")).append("','").append(rs.getString("REGISTER_ID")).append("','").append(rs.getString("CHECKER_ID")).append("','").append(rs.getString("CHANGER_ID")).append("','").append(rs.getString("REGISTER_TIME")).append("','").append(rs.getString("CHECK_TIME")).append("','").append(rs.getString("CHANGE_TIME")).append("','").append(rs.getString("LATELY_CHANGE_TIME")).append("','").append(rs.getString("DELETE_TIME")).append("','").append(rs.getString("RECOVERY_TIME")).append("','").append(rs.getString("EXCEL_TAG")).append("','").append(rs.getString("CHANGE_TAG")).append("','").append(rs.getString("MAJOR_CHANGE_TAG")).append("','").append(rs.getString("TRAINING_CHECK_TAG")).append("','").append(rs.getString("BONUS_CHECK_TAG")).append("','").append(rs.getString("LICENSE_TAG")).append("')").toString();
							hr_db.executeUpdate(sqll);
						}
						String sql3 = (new StringBuilder("select file_change_amount,training_amount from hr_file where human_ID='")).append(human_ID).append("'").toString();
						rs = hr_db.executeQuery(sql3);
						if (rs.next())
						{
							int file_change_amount1 = rs.getInt("file_change_amount") + 1;
							int training_amount1 = rs.getInt("training_amount") + 1;
							sql3 = (new StringBuilder("update hr_file set change_time='")).append(register_time).append("',file_change_amount='").append(file_change_amount1).append("',training_amount='").append(training_amount1).append("',training_check_tag='0' where human_ID='").append(human_ID).append("'").toString();
							hr_db.executeUpdate(sql3);
						}
					} else
					{
						for (Iterator ite = rsList.iterator(); ite.hasNext(); hr_db.executeUpdate(sql))
						{
							elem = (String[])ite.next();
							sql = (new StringBuilder("insert into hr_workflow(config_id,object_ID,type_id,describe1,describe2,training_time) values ('")).append(elem[0]).append("','").append(human_ID).append("','05','").append(elem[1]).append("','").append(elem[2]).append("','").append(training_time).append("')").toString();
						}

					}
					response.sendRedirect("hr/training/register_ok_a.jsp");
				}
				catch (Exception ex)
				{
					out.println((new StringBuilder("error")).append(ex).toString());
				}
				hr_db.commit();
				hr_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception exception) { }
	}
}
